package com.hison.courseselectionsystem.controller;

import com.hison.courseselectionsystem.service.CourseService;
import com.hison.courseselectionsystem.service.CourseTeacherService;
import com.hison.courseselectionsystem.service.TeacherService;
import com.hison.courseselectionsystem.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * @ClassName: TeacherCourseController
 * @Descripiton: TODO
 * @Author: 小郑
 * @Date： 2023/11/17 13:06
 * @Version：1.8
 **/
@RequestMapping("/teachercourse")
@RestController
@Api(value = "教师课程接口", description = "添加教授课程，删除教授课程，修改教授课程,查看选了自己课程的学生")
public class TeacherCourseController {

    @Resource
    private CourseTeacherService courseTeacherService;
    @Resource
    private CourseService courseService;

    /**
     * 添加自己教的课程
     *
     * @param teacherId
     * @param courseId
     * @return {@link Result}
     */
    @ApiOperation(value = "添加自己可以教的课程 ", notes = "添加教授课程", produces = "application/json")
    @PostMapping("/add")
    public Result add(@RequestParam("teacherId") Integer teacherId, @RequestParam("courseId") Integer courseId) {
        return courseTeacherService.add(teacherId, courseId);
    }

    //查找自己教的课程
    @ApiOperation(value = "获取选择了自己课程的学生", notes = "根据传过来的教师id进行查询", produces = "application/json")
    @GetMapping("/getStudent")
    public Result getStudent(@RequestParam("teacherId") Integer teacherId) {
        return courseTeacherService.getStudent(teacherId);
    }


    /**
     * 查找所有课程信息
     *
     * @return {@link Result}
     */
    @ApiOperation(value = "查看所有课程")
    @GetMapping("/allCourse")
    public Result getAllCourse() {
        return courseService.getAllCourse();
    }


    //查找选择了自己课程的学生信息
    @ApiOperation(value = "查看选了自己课程的学生", notes = "查看选了自己课程的学生", produces = "application/json")
    @GetMapping("/getStudentlist")
    public Result getStudentlist(@RequestParam("Courseid") Integer courseid, @RequestParam("teachersId") String teacherid) {
        return  courseTeacherService.getStudentlist(courseid, teacherid);
    }
}